package cn.wolfcode.cmis.qo;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Setter
@Getter
public class PageResult<T> {
    private Integer currentPage;
    private Integer pageSize;
    private Integer pervPage;
    private Integer nextPage;
    private Integer totalPage;
    private Integer totalCount;
    private List<T> data;

    public PageResult(Integer currentPage, Integer pageSize, Integer totalCount, List<T> data) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;
        this.totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        this.pervPage = currentPage - 1 >= 1 ? currentPage - 1 : 1;
        this.nextPage = currentPage + 1 <= totalPage ? currentPage + 1 : totalPage;
    }
}
